/**
 * 
 */
package com.zte.claa.inficombo.csa.app.util;

import org.apache.commons.lang3.StringUtils;

/**
 * @author 0283000138
 *
 */
public class AlarmUtils {

	private static final String SPLIT_CHAR = "@";
	
	
	//生成AlarmKey
	public static String generateAlarmKey(String devEui, String devType, String alarmCode){
		return generateAlarmKey(devEui, devType, alarmCode, null);
	}
	
	//生成AlarmKey, 带关联对象ID
	public static String generateAlarmKey(String devEui, String devType, String alarmCode, String relaobjid){
		return StringUtils.trimToEmpty(devEui) + SPLIT_CHAR + StringUtils.trimToEmpty(devType) + SPLIT_CHAR + StringUtils.trimToEmpty(alarmCode) + SPLIT_CHAR + StringUtils.trimToEmpty(relaobjid);
	}
	
	public static String generateForwardKey(String projectid, String devType, String alarmCode){
		if (StringUtils.isEmpty(alarmCode)){
			return projectid + SPLIT_CHAR + devType;
		}
		else {
			return projectid + SPLIT_CHAR + devType + SPLIT_CHAR + alarmCode;
		}
	}
	
	public static String generateDalayRuleKey(String projectId, String devType, String alarmcode){
		return StringUtils.trimToEmpty(projectId) + SPLIT_CHAR + StringUtils.trimToEmpty(devType) + SPLIT_CHAR + StringUtils.trimToEmpty(alarmcode);
	}
	
	public static String generateFilterRuleKey(String projectId, String devType, String alarmcode){
		return StringUtils.trimToEmpty(projectId) + SPLIT_CHAR + StringUtils.trimToEmpty(devType) + SPLIT_CHAR + StringUtils.trimToEmpty(alarmcode);
	}
	
	
}
